<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    function Animal(name, color, speci) {
      this.name = name
      this.color = color
      this.speci = speci
      this.action = function () {
        console.log('eat');
      }
    }
    Animal.prototype.sex = '母'
    Animal.prototype.leg = function () {
      console.log('陆地生物');
    }

    var ani = new Animal()
    console.log(Animal.prototype);
    console.log(ani.__proto__);
    console.log(Animal.prototype === ani.__proto__);

    console.log(Animal.prototype.constructor);
    console.log(ani.__proto__.constructor);
    console.log(Animal.prototype.constructor === ani.__proto__.constructor);
    //原型链的判断.hasOwnProperty可以判断一个属性定义在对象本身而不是继承原型链的方法
    console.log(ani.hasOwnProperty('speci'));
    console.log(ani.hasOwnProperty('sex'));
    console.log(ani.hasOwnProperty('name'));
    //Animal.prototype.isPrototypeOf(ani)接收一个对象，用来判断当前对象是否在传入的参数对象的原型链上
    console.log(Animal.prototype.isPrototypeOf(ani));

  </script>
</body>

</html>